package presentacion;

import global.DatosGlobales;
import java.awt.Dimension;
import presentacion.catalogos.Alumnos;
import presentacion.catalogos.Carreras;
import presentacion.catalogos.Materias;
import presentacion.catalogos.Profesores;
import presentacion.procesos.CapturaCalificaciones;
import presentacion.procesos.Inscripcion;

/**
 *
 * @author samuel
 */
public class Principal extends javax.swing.JFrame {
    private static Principal principal = null;
    private Integer TipoAcceso;
    
    public Principal() {
        initComponents();
        this.setSize(new Dimension(1000, 1000));
        itemCarreras.setVisible(false);
        itemProfesores.setVisible(false);
        this.jMenuItem3.setVisible(false);
        Accesos();
    }
    public static Principal getPrincipal(){
        if(principal == null ){
            principal = new Principal();
        }
        return principal;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        desktopPanel = new javax.swing.JDesktopPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        mnuMiniSega = new javax.swing.JMenu();
        jMenuItem5 = new javax.swing.JMenuItem();
        mnuCatalogos = new javax.swing.JMenu();
        itemAlumnos = new javax.swing.JMenuItem();
        itemProfesores = new javax.swing.JMenuItem();
        itemMaterias = new javax.swing.JMenuItem();
        itemCarreras = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();

        jMenu1.setText("jMenu1");

        jMenu2.setText("jMenu2");

        jMenuItem2.setText("jMenuItem2");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        mnuMiniSega.setText("MIni Sega");

        jMenuItem5.setText("Salir");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        mnuMiniSega.add(jMenuItem5);

        jMenuBar1.add(mnuMiniSega);

        mnuCatalogos.setText("Catalogos");

        itemAlumnos.setText("Alumnos");
        itemAlumnos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemAlumnosActionPerformed(evt);
            }
        });
        mnuCatalogos.add(itemAlumnos);

        itemProfesores.setText("Profesores");
        itemProfesores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemProfesoresActionPerformed(evt);
            }
        });
        mnuCatalogos.add(itemProfesores);

        itemMaterias.setText("Materias");
        itemMaterias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemMateriasActionPerformed(evt);
            }
        });
        mnuCatalogos.add(itemMaterias);

        itemCarreras.setText("Carreras");
        itemCarreras.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemCarrerasActionPerformed(evt);
            }
        });
        mnuCatalogos.add(itemCarreras);

        jMenuBar1.add(mnuCatalogos);

        jMenu3.setText("Procesos");

        jMenuItem3.setText("Captura de Calificaciones");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem3);

        jMenuItem1.setText("Inscripcion");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem1);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 549, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 354, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void itemAlumnosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemAlumnosActionPerformed
        Alumnos alumnosCatalogo = new Alumnos();
        desktopPanel.add(alumnosCatalogo);
        alumnosCatalogo.show();
        
    }//GEN-LAST:event_itemAlumnosActionPerformed

    private void itemCarrerasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemCarrerasActionPerformed
        Carreras carreraCatalogo = new Carreras();
        desktopPanel.add(carreraCatalogo);
        carreraCatalogo.show();
    }//GEN-LAST:event_itemCarrerasActionPerformed

    private void itemMateriasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemMateriasActionPerformed
        Materias materiasCatalogo = new Materias();
        desktopPanel.add(materiasCatalogo);
        materiasCatalogo.show();
    }//GEN-LAST:event_itemMateriasActionPerformed

    private void itemProfesoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemProfesoresActionPerformed
        Profesores profesoresCatalogo = new Profesores();
        desktopPanel.add(profesoresCatalogo);
        profesoresCatalogo.show();                
    }//GEN-LAST:event_itemProfesoresActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        Login login = new Login();
        login.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        Inscripcion ins = new Inscripcion();
        desktopPanel.add(ins);
        ins.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        CapturaCalificaciones cc = new CapturaCalificaciones();
        desktopPanel.add(cc);
        cc.setVisible(true);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
       /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
          
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Principal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane desktopPanel;
    private javax.swing.JMenuItem itemAlumnos;
    private javax.swing.JMenuItem itemCarreras;
    private javax.swing.JMenuItem itemMaterias;
    private javax.swing.JMenuItem itemProfesores;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenu mnuCatalogos;
    private javax.swing.JMenu mnuMiniSega;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the TipoAcceso
     */
    public Integer getTipoAcceso() {
        return TipoAcceso;
    }

    /**
     * @param TipoAcceso the TipoAcceso to set
     */
    public void setTipoAcceso(Integer TipoAcceso) {
        this.TipoAcceso = TipoAcceso;
    }
    
    private void Accesos(){
        boolean permiso;
        permiso = DatosGlobales.getInstance().getIpGeneral().equals("192.168.1.3")?true:false;
        if (permiso){
                itemCarreras.setVisible(true);
                itemProfesores.setVisible(true);
            }
        }
}
